<?php

namespace App\Jobs;

use App\Services\Comm\QueueService;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Log;

class HttpQueueJob extends BaseJob implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    public $data ;

    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct($data)
    {
        $this->data = $data ;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        try {
            (new QueueService())->execHttpReqQueue($this->data);
        } catch (\Exception $e) {
            $this->msg('Exception '.json_encode($e->getMessage()));
            Log::info("HttpQueueJob Exception :".json_encode($e->getMessage()));
            throw $e;
        }
    }

    /**
     * 获取Jobs的Data数据
     * @return mixed
     */
    public function getData()
    {
        return $this->data;
    }
}
